<template>
  <div class="my-study">
    <div class="mescroll"  ref="mescroll">
      <div class="list" v-if="lists && lists.length>0">
        <div v-for="(item,index) in lists" :key="index" class="item">
          <div class="top">
            <img src="@/assets/wodexuexi01.png" alt="">
            <div class="top-title">
              <p class="title">{{item.title}}</p>
              <p class="time">{{item.create_time}} 打卡</p>
            </div>
          </div>
          <p class="who">孩子：{{item.truename}}  ·  {{item.age}}岁  ·  家长：{{item.parent}}</p>
          <div class="cons">
            <p class="cons-title">点评内容</p>
            <div class="comment-con" v-if="item.review==1" v-html="item.content">
            </div>
            <div class="comment-con" v-else>暂无点评</div>
            <p class="cons-time" v-if="item.review==1">评论于 {{item.review_time}}</p>
            <p class="cons-time" v-else></p>
          </div>
        </div>
      </div>
      <div class="none" v-show="noDate">        
        <img src="@/assets/sousuomendian04.png" alt="">
        <p>暂无相关内容</p>
      </div>
    </div>
  </div>
</template>

<script>
  import {mystudy} from '@/api/api'
  import MeScroll from 'mescroll.js'
  import 'mescroll.js/mescroll.min.css'
  import none from '@/components/none'
  export default {
    components: {
      none
    },
    data () {
      return {
        lists: [],
        noDate: false,
      }
    },
    created () {
    },
    mounted () {
      this.mescroll = new MeScroll(this.$refs.mescroll, { 
        up: {
          callback: this.upCallback
        }
      })
    },
    methods: {
      upCallback (page) {
        mystudy(page.num, page.size).then((res) => {
          console.log(res)
          if (page.num == 1){
            this.lists = []
          }
          if(res.data == null){
            console.log(1)
            this.mescroll.endErr()
            return
          }
          this.$nextTick(() => {
            this.mescroll.endSuccess(res.data.data.list.length);
          })
          this.lists = this.lists.concat(res.data.data.list)
          if(this.lists.length == 0){
            this.noDate = true
          }
        }).catch((err) => {
          console.dir(err)
          this.mescroll.endErr()
        })
      }
    }
  }
</script>

<style lang="stylus" scoped>
.my-study
  min-height 100vh
  background-color #f5f5f5
  padding-bottom 1rem
  box-sizing border-box
  .mescroll
    position fixed
    top 0
    bottom 0
    height auto
    width 100vw
    overflow-x hidden
    .top-img
      float left
    .search
      float left
      width 92%
      margin-left 4%
      text-align center
      background-color #fff
      height 4.5rem
      line-height 4.5rem
      margin-top -2.25rem
      margin-bottom 1rem
      img
        display inline-block
        vertical-align middle
        width 1.6rem
      span
        display inline-block
        vertical-align middle
        font-size 1.3rem
        color #172F6D
        margin-left .5rem
  .item
    background-color #fff
    margin-bottom 1rem
    padding 0 1.5rem
    .top
      position relative
      height 7.4rem
      padding 1.8rem 0
      box-sizing border-box
      border-bottom 1px solid #e6e6e6
      img
        position absolute
        width 1.2rem
        left 0
        top 2rem
      .title
        color #333333
        font-size 1.5rem
        line-height 1.6rem
        height 1.6rem
        padding-left 2.7rem
        font-weight bold
      .time
        font-size 1.2rem
        height 1.2rem
        line-height 1.2rem
        color #999
        padding-left 2.7rem
        margin-top 1rem
    .who
      line-height 2.5rem
      height 2.5rem
      margin 2rem 0
      border-left .4rem solid #b3b3b3
      font-size 1.3rem
      color #666
      padding-left 2.3rem
    .cons
      padding-bottom 2rem
      .cons-title
        font-size 1.7rem
        color #000
        font-weight bold
        margin-bottom 1rem
      .comment-con
        p
          font-size 1.3rem
          color #333
          line-height 2.7rem
      .cons-time
        font-size 1.2rem
        color #999
        margin-top 1.2rem
    &:last-child
      margin-bottom 0
  .none
    img
      position absolute
      top 20.3rem
      width 7.25rem
      left 50%
      margin-left -3.625rem
    p
      color #666
      font-size 1.3rem
      text-align center
      position absolute
      width 100%
      top 32rem
</style>
